package physics;




public class Vector {

	private double angle;	//in radians
	private double force;
	
	public Vector(double angle, double force){
		this.angle = angle;
		setForce(force);
		
	}
	
	/**
	 * Set the force of this vector.
	 * @param 	force
	 * 				The new force of this vector.
	 */
	private void setForce(double force){
		this.force = force;	
	}
	
	/**
	 * Set the angle of this vector.
	 * @param 	angle
	 * 				The new angle for this vector.
	 */
	private void setAngle(Double angle){
		this.angle = angle;
	}
	
	/**
	 * Add an other vector to this one.
	 * @param 	vector
	 * 				The vector to add. 
	 */
	public void addVector(Vector vector){
		double newXforce = this.getxForce() + vector.getxForce();
		double newYforce = this.getyForce() + vector.getyForce();
		this.setForce(Coordinate.getDistance(new Coordinate(0, 0), new Coordinate(newXforce, newYforce)));
		this.setAngle(Coordinate.getAngle(new Coordinate(0, 0), new Coordinate(newXforce, newYforce)));
	}
	
	/**
	 * @return	The angle of this vector.
	 * 			The x-axis is configured as 0 radians. 
	 */
	public double getAngle() {
		return angle;
	}

	/**
	 * @return The force of this vector.
	 */
	public double getForce() {
		return force;
	}

	/**
	 * @return	Force in the direction of the x-axis.
	 */
	public double getxForce() {
		return Math.cos(angle) * force;
	}

	/**
	 * @return Force in direction of the y-axis.
	 */
	public double getyForce() {
		return -Math.sin(angle) * force;
	}


	public String toString(){
		return "angle: " + angle + "     | force: " + force;
	}
	
	
}
